﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Remote_Commander
{
    public partial class frm_computerFilter : Form
    {
        //Public properties, accessed by frm_MainWindow
        public bool allComputersSelected
        {
            get;
            set;
        }

        public string groupName
        {
            get;
            set;
        }

        //Constructor
        public frm_computerFilter()
        {
            InitializeComponent();

            //Select the all computers radio button
            allComputersSelected = true;

            //Create the filter option items and add them to the filter list
        }

        private void rad_filterComputers_CheckedChanged(object sender, EventArgs e)
        {
            //User wants to filter computers
            if (rad_filterComputers.Checked == true)
            {
                allComputersSelected = false;

                //Enable the filter fields
                txt_groupName.Enabled = true;
            }
            //User wants to show all computers
            else
            {
                allComputersSelected = true;

                //Disable the filter fields
                txt_groupName.Enabled = false;
            }
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {
            //Ensure that a group name is entered
            if (allComputersSelected == false && txt_groupName.Text == string.Empty)
            {
                //No group name
                MessageBox.Show("Error: You must enter a group name.");
            }
            else if (allComputersSelected == false && txt_groupName.Text != string.Empty)
            {
                //Group name entered
                groupName = txt_groupName.Text;
                this.Close();
            }
            else
            {
                //All computers selected
                this.Close();
            }
            
            
        }
    }
}
